package com.huawei.appgallery.common.media.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View.MeasureSpec;
import android.widget.RelativeLayout;

public class SquareLayout extends RelativeLayout {
    private int ˎ;

    public SquareLayout(Context context) {
        super(context);
    }

    public SquareLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(attributeSet);
    }

    public SquareLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˋ(attributeSet);
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void ˋ(android.util.AttributeSet r6) {
        /*
        r5 = this;
        if (r6 == 0) goto L_0x001b;
    L_0x0002:
        r0 = 0;
        r1 = r5.getContext();	 Catch:{ Exception -> 0x001c, all -> 0x002c }
        r2 = o.ble$f.ߴ;	 Catch:{ Exception -> 0x001c, all -> 0x002c }
        r0 = r1.obtainStyledAttributes(r6, r2);	 Catch:{ Exception -> 0x001c, all -> 0x002c }
        r1 = o.ble$f.ՙ;	 Catch:{ Exception -> 0x001c }
        r2 = 1;
        r1 = r0.getInteger(r1, r2);	 Catch:{ Exception -> 0x001c }
        r5.ˎ = r1;	 Catch:{ Exception -> 0x001c }
        if (r0 == 0) goto L_0x001b;
    L_0x0018:
        r0.recycle();
    L_0x001b:
        return;
    L_0x001c:
        r1 = move-exception;
        r1 = o.blf.ˋ;	 Catch:{ all -> 0x0036 }
        r2 = "SquareLayout";
        r3 = "init error";
        r1.ˏ(r2, r3);	 Catch:{ all -> 0x0036 }
        if (r0 == 0) goto L_0x001b;
    L_0x0028:
        r0.recycle();
        goto L_0x001b;
    L_0x002c:
        r1 = move-exception;
        r4 = r1;
        r1 = r0;
        r0 = r4;
    L_0x0030:
        if (r1 == 0) goto L_0x0035;
    L_0x0032:
        r1.recycle();
    L_0x0035:
        throw r0;
    L_0x0036:
        r1 = move-exception;
        r4 = r1;
        r1 = r0;
        r0 = r4;
        goto L_0x0030;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.appgallery.common.media.widget.SquareLayout.ˋ(android.util.AttributeSet):void");
    }

    protected void onMeasure(int i, int i2) {
        setMeasuredDimension(getDefaultSize(0, i), getDefaultSize(0, i2));
        int size = MeasureSpec.getSize(i);
        int size2 = MeasureSpec.getSize(i2);
        int measuredWidth = getMeasuredWidth();
        int measuredHeight = getMeasuredHeight();
        if (size >= measuredWidth) {
            size = measuredWidth;
        }
        if (size2 >= measuredHeight) {
            size2 = measuredHeight;
        }
        switch (this.ˎ) {
            case 0:
                size = size2;
                break;
            case 1:
                size2 = size;
                break;
            case 2:
                if (size <= size2) {
                    size = size2;
                    break;
                } else {
                    size2 = size;
                    break;
                }
            case 3:
                if (size >= size2) {
                    size = size2;
                    break;
                } else {
                    size2 = size;
                    break;
                }
        }
        super.onMeasure(MeasureSpec.makeMeasureSpec(size, 1073741824), MeasureSpec.makeMeasureSpec(size2, 1073741824));
    }
}
